import pytest

from PO.V5.index_page import IndexTask
from PO.V5.login_page import loginTask
from PO.utils import DriverUtil, get_alert_msg


class TestLogin:

    def setup_class(self):
        self.driver = DriverUtil.get_driver()
        self.index_task = IndexTask()  # 实例化首页业务层
        self.login_task = loginTask()  # 实例化登录页业务层

    @staticmethod
    def teardown_class():
        DriverUtil.quit_driver()

    def setup(self):
        self.driver.get("http://127.0.0.1")
        self.index_task.go_to_login_page()  # 跳转页面

    def teardown(self):
        pass

    def test_account_no_exist(self):
        self.login_task.success_login("15021241001", "123456", "8888")
        msg = get_alert_msg()
        print(msg)

    def test_wrong_password(self):
        self.login_task.success_login("15021241000", "12345", "8888")
        msg = get_alert_msg()
        print(msg)


if __name__ == '__main__':
    pytest.main(["-sv", "PO/V5/tpshop_login.py"])
